package com.xgb.array;

public class MyArray {

    static int[] arr = new int[10];

    public static void main(String args[]){
        arr = addlengthArray(arr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = i;
            System.out.println(arr[i]);
        }
    }
    /**
     * 支持动态扩容的数组
     * @param arr
     * @return
     */
    public static int[] addlengthArray(int[] arr){
        int[] newArr = new int[arr.length*2];
        System.arraycopy(arr,0,newArr,0,arr.length);
        return newArr;
    }
}
